package com.usian.excetion;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//@ControllerAdvice
public class BaseExcetionHandler {

    @ExceptionHandler(NullPointerException.class)
//    @ResponseBody
    public String error(Exception e){
        System.out.println("调用公共异常处理");
//        return "出现了空指针异常!!!";
        return "null_error";
    }

    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public String error2(ArithmeticException e){
        System.out.println("调用公共异常处理");
        return "出现了算术异常!!!";
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public String error3(ArithmeticException e){
        System.out.println("调用公共异常处理");
        return "出现了未知异常!!!";
    }

}
